package com.qf.flash.mvp.presenter;

import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.http.HttpManager;
import com.qf.flash.model.BalanceBean;
import com.qf.flash.mvp.contract.AccountDetailContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseResponse;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

import java.util.List;

public class AccountDetailPresenter extends BasePresenter<AccountDetailContract.View> implements AccountDetailContract.Presenter {
    @Override
    public void getAccountDetail(String type, int pageNo, int pageSize) {
        String uid = UserMgr.getInstance().getLoginUser().getUid();
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
            .GET_ACCOUNTDETAIL_LIST(uid,type,pageNo,pageSize)
                .compose(RxUtils.handleBaseResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<BaseResponse<List<BalanceBean>>>(mRootView) {
                    @Override
                    public void onSuccess(BaseResponse<List<BalanceBean>> listBaseResponse) {
                        mRootView.setAccountDetail(listBaseResponse.getData(),listBaseResponse.getTotalPage());
                    }
                })

        );
    }
}
